<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/22
 * Time: 0:46
 * ps aft | grep tcp.php
 */
$client = new swoole_client(SWOOLE_SOCK_TCP);

if (!$client->connect('127.0.0.1', 9501)) {
    echo '连接失败';die;
}

//php cli 常量
fwrite(STDOUT, '请输入消息:');
$msg = trim(fgets(STDOUT));

//发送信息给server
$client->send($msg);

//接受server返回的信息
$response = $client->recv();

echo $response;